/* GUI CONVERTED from rcrp07a.i (converter v1.76) Fri May  3 13:21:40 2002 */
/* rcrp07a.i - Release Management Customer Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.13.2.3 $                                                     */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 7.3    LAST MODIFIED: 10/06/92           BY: WUG *G462*    */
/* REVISION: 7.3    LAST MODIFIED: 09/29/93           BY: WUG *GG02*    */
/* REVISION: 7.3    LAST MODIFIED: 04/08/94           BY: WUG *GJ29*    */
/* REVISION: 7.3    LAST MODIFIED: 07/23/96           BY: *G29C* Ajit Deodhar */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*          */
/* REVISION: 8.6    LAST MODIFIED: 06/11/97           BY: *J1SX* Aruna Patil  */
/* REVISION: 8.6    LAST MODIFIED: 06/20/97           BY: *H19T* Seema Varma  */
/* REVISION: 8.6    LAST MODIFIED: 08/08/97           BY: *J1YQ* Suresh Nayak */
/* REVISION: 8.6    LAST MODIFIED: 10/07/97           BY: bvm  *K0MJ*         */
/* REVISION: 8.6E   LAST MODIFIED: 02/23/98           BY: *L007* A. Rahane    */
/* REVISION: 8.6E   LAST MODIFIED: 10/04/98           BY: *J314* Alfred Tan   */
/* REVISION: 9.1    LAST MODIFIED: 07/25/00           BY: *N0GQ* Mudit Mehta  */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.13.2.3 $    BY: Katie Hilbert         DATE: 04/15/02  ECO: *P03J*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* SHIPPING SUMMARY REPORT INCLUDE */

/*
{1} = "break by ..."
*/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i}
{wbrp02.i}
{rcrpvar.i "shared"}

define shared variable start         as date label "Start Date".
define shared variable sdate         as date extent 14.
define shared variable interval      as integer extent 14.
define shared variable dwm           as character format "x(1)"
                                     label "Day/Week/Month".
define shared variable idays         as integer format ">9"
                                     label "Per Column".
define shared variable num_intervals as integer.

define buffer custad for ad_mstr.
define buffer shipad for ad_mstr.
define buffer dockad for ad_mstr.

define variable net_req            as decimal.
define variable cum_net_req        as decimal.
define variable prior_cum_net_req  as decimal.
define variable cum_net_req_bucket as decimal
                                   format ">>>>>>>9" extent 13.
define variable net_req_bucket     as decimal
                                   format ">>>>>>>9" extent 13.
define variable i                  as integer no-undo.
define variable nonwdays           as integer.
define variable workdays           as integer extent 14 format "->>>,>>9".
define variable overlap            as integer.
define variable d_start            as date no-undo.

FORM /*GUI*/  with STREAM-IO /*GUI*/  frame heading width 80.

mainloop:
for each scx_ref
      where scx_type      = 1
        and scx_shipfrom  >= shipfrom_from
        and scx_shipfrom  <= shipfrom_to
        and scx_shipto    >= shipto_from
        and scx_shipto    <= shipto_to
        and scx_part      >= part_from
        and scx_part      <= part_to
        and scx_po        >= po_from
        and scx_po        <= po_to
        and scx_order     >= order_from
        and scx_order     <= order_to
        and scx_custref   >= custref_from
        and scx_custref   <= custref_to
        and scx_modelyr   >= modelyr_from
        and scx_modelyr   <= modelyr_to
   no-lock,
   each sod_det
      where sod_nbr   = scx_order
        and sod_line  = scx_line
        and sod_dock >= dock_from
        and sod_dock <= dock_to
   no-lock,
   each so_mstr
      where so_nbr   = sod_nbr
        and so_cust  >= cust_from
        and so_cust  <= cust_to
   no-lock,
   each sch_mstr
      where sch_type     = 3
        and sch_nbr      = sod_nbr
        and sch_line     = sod_line
        and sch_rlse_id  = sod_curr_rlse_id[3]
   no-lock
      {1}:

   if first-of(sod_dock)
   then do:
      find si_mstr
         where si_site = scx_shipfrom
      no-lock.
      find custad
         where custad.ad_addr = so_cust
      no-lock no-error.
      find shipad
         where shipad.ad_addr = scx_shipto
      no-lock no-error.
      find dockad
         where dockad.ad_addr = sod_dock
      no-lock no-error.

      display
         skip(1)
         getTermLabelRtColon("SHIP-FROM",10)     to 10  format "x(10)"
         si_site
         si_desc
         scx_order
         scx_line
         getTermLabelRtColon("CUSTOMER",10)      to 10  format "x(10)"
         so_cust
         if available custad then
            custad.ad_name
         else
            "" @ custad.ad_name
         skip
         getTermLabelRtColon("SHIP-TO",10)       to 10  format "x(10)"
         scx_shipto
         if available shipad then
            shipad.ad_name
         else
            "" @ shipad.ad_name
         skip
         getTermLabelRtColon("DOCK",10)          to 10  format "x(10)"
         sod_dock
         if available dockad then
            dockad.ad_name
         else
            "" @ dockad.ad_name
         skip(1)
         space(14)
         getTermLabel("PAST",8) format "x(8)"
         sdate[2 for 12]
         skip
         space(14)
         sdate[2] - 1
         sdate[3] - 1
         sdate[4] - 1
         sdate[5] - 1
         sdate[6] - 1
         sdate[7] - 1
         sdate[8] - 1
         sdate[9] - 1
         sdate[10] - 1
         sdate[11] - 1
         sdate[12] - 1
         sdate[13] - 1
         sdate[14] - 1
         skip space(14)
         "-------- -------- -------- -------- -------- -------- --------"
         "-------- -------- -------- -------- -------- --------"
      with frame heading page-top width 132
         no-box no-attr-space no-labels STREAM-IO /*GUI*/ .
   end.

   update net_req_bucket = 0.

   prior_cum_net_req = max(sch_pcr_qty - sod_cum_qty[1],0).

   if so_cum_acct then
   do:
      {rcrp07.i &date=sch_pcs_date &qty=prior_cum_net_req}
   end.
   else do:
      assign
         d_start = start - 5
         prior_cum_net_req = 0.
      {rcrp07.i &date=d_start &qty=prior_cum_net_req}
   end.

   for each schd_det
       where schd_type     = sch_type
         and schd_nbr      = sch_nbr
         and schd_line     = sch_line
         and schd_rlse_id  = sch_rlse_id
      no-lock:

      assign
         cum_net_req = max(schd_cum_qty - sod_cum_qty[1],0)
         net_req = cum_net_req - prior_cum_net_req
         prior_cum_net_req = cum_net_req.

      if not so_cum_acct then
         assign
            net_req = schd_discr_qty - schd_ship_qty
            prior_cum_net_req = 0.

      {rcrp07.i &date=schd_date &qty=net_req}
   end.

   update cum_net_req_bucket = 0
   cum_net_req = 0.

   do i = 1 to num_intervals:
      assign
         cum_net_req = cum_net_req + net_req_bucket[i]
         cum_net_req_bucket[i] = cum_net_req.
   end.

   assign
      workdays = 0
      interval[1] = ?.
   do i = 2 to num_intervals:
      interval[i - 1] = sdate[i] - sdate[i - 1].
   end.

   {mfcwdays.i sod_site}

   display

      getTermLabelRtColon("ITEM_NUMBER",12) format "x(12)"
      space(1)
      sod_part
      space(2)
      getTermLabelRtColon("PO_NUMBER",3) format "x(3)"
      space(1)
      sod_contr_id                  format "x(22)"
      space(2)
      getTermLabelRtColon("CUSTOMER_REFERENCE",19) format "x(19)"
      space(1)
      scx_custref
      space(1)
      getTermLabelRtColon("MODEL_YEAR",11) format "x(11)"
      space(1)
      scx_modelyr
      getTermLabelRtColon("RELEASE_ID",11) format "x(11)"
      space(1)
      sch_rlse_id
      sod_custpart                  format "x(30)" at 14
      skip
      getTermLabel("WORKDAYS",13) format "x(14)"
      "" @ workdays[1]
      workdays[2 for 12]
      skip
      getTermLabel("NET_QTY_DUE",13) format "x(14)"
      net_req_bucket[1 for 13]
      skip
      getTermLabel("CUM_QTY_DUE",13) format "x(14)"
      cum_net_req_bucket[1 for 13]
      skip(2)
   with width 132 no-box no-attr-space no-labels STREAM-IO /*GUI*/ .

   
/*GUI*/ {mfguichk.i  &warn=false &label=mainloop} /*Replace mfrpchk*/


   if last-of(sod_dock) then
   do:
      hide frame heading.
      page.
   end.
end.
{wbrp04.i}
